package com.sdweizan.sdk.bytedance.bean.notify;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.annotation.JSONField;
import com.sdweizan.sdk.bytedance.bean.refund.general.BdRefundItemOrderDetail;
import java.util.List;
import lombok.Data;
import lombok.EqualsAndHashCode;

/** 通用交易-退款結果回調** */
@EqualsAndHashCode(callSuper = true)
@Data
public class BdOrderRefundResultNotifyRequest extends BdBaseNotify {
  public Msg getMessage() {
    return JSON.parseObject(super.getMsg(), Msg.class);
  }

  @Data
  static class Msg {
    @JSONField(name = "app_id")
    private String appId;

    /** 退款状态枚举值：SUCCESS：退款成功 FAIL：退款失败* */
    @JSONField(name = "status")
    private String status;

    /** 抖音开平侧退款单号 * */
    @JSONField(name = "refund_id")
    private String refundId;

    /** 抖音开平侧订单号 * */
    @JSONField(name = "order_id")
    private String orderId;

    /** 开发者自定义的退款单号（可能为空) * */
    @JSONField(name = "out_refund_no")
    private String outRefundNo;

    @JSONField(name = "refund_total_amount")
    private Long refundTotalAmount;

    /** 是否为分账后退款* */
    @JSONField(name = "is_all_settled")
    private Boolean isAllSettled;

    /** 结果描述信息，如失败原因* */
    private String message;

    /** 退款来源类型，枚举值： 1: 用户发起 2：开发者发起 4：抖音客服退款 * */
    @JSONField(name = "refund_type")
    private Integer refundType;

    /** 退款时间戳，单位为毫秒* */
    @JSONField(name = "event_time")
    private Long eventTime;

    /** cp 自定义字段* */
    @JSONField(name = "cp_extra")
    private String cpExtra;

    @JSONField(name = "refund_item_detail")
    private List<RefundItemDetail> refundItemDetail;

    @Data
    static class RefundItemDetail {

      /***用户需要退款多少个商品单 ***/
      @JSONField(name = "item_order_quantity")
      private Integer item_order_quantity;

      /***本次退款的商品单列表 ***/
      @JSONField(name = "item_order_detail")
      private List<BdRefundItemOrderDetail> itemOrderDetail;
    }
  }
}
